// pages/user/user/userInfo/userInfo.js
const app = getApp();
import Api from '../../../../utils/http';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    userStatus: 1, //当identityStatus 为1时，userStatus为1是部门管理员，为2是用户
  },
  //跳转绑定手机号
  toChangeBindTel: function (e) {
    var that = this;
    let verification = that.data.userInfo.verification
    console.log(that.data)
    if (verification != 1) {
      wx.navigateTo({
        url: '/pages/user/user/mobileAuth/mobileAuth',
      })
    }else{

      wx.navigateTo({
        url: '/pages/user/user/bindTelStepOne/bindTelStepOne',
      })
    }
  },
  //个人二维码
  code:function(){
    wx.navigateTo({
      url: '/pages/user/user/userCode/userCode?codeType=1',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var userStatus = options.userStatus;
    that.setData({
      userStatus: userStatus
    });
    that.getuserInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },
  //个人信息
  getuserInfo: function () {
    var that = this;
    let uid = wx.getStorageSync('userid');
    var param = {
      uid: uid.id,
      user_type: uid.user_type,
    };
    console.log(param)
    Api.ajax("/app/Zpersonalcenter/userInfo", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          userInfo: res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})